Skip to content

feat: add query layer (CM-1059)#3942

Open
ulemons wants to merge 50 commits intomainfrom
feat/add-query-layer
Open

feat: add query layer (CM-1059)#3942
ulemons wants to merge 50 commits intomainfrom
feat/add-query-layer

Conversation

@ulemons
Copy link
Contributor

@ulemons ulemons commented Mar 20, 2026

DevStats Affiliations API + Generic DAL resolver

Implements the /v1/dev-stats/affiliations endpoint that allows external tools (e.g. DevStats/gitdm) to resolve GitHub contributor affiliations in bulk.

API

POST /v1/dev-stats/affiliations
Authorization: Bearer <api-key>

{ "githubHandles": ["handle1", "handle2"] }

Accepts up to 1,000 handles per request. Returns resolved, non-overlapping affiliation periods per contributor, sorted by most recent first.

Implementation

services/libs/data-access-layer/src/affiliations/ — new generic module, usable by any consumer:

  • IAffiliationPeriod — public type representing a single affiliation window
  • resolveAffiliationsByMemberIds — bulk resolver for up to N members in 2 DB queries
  • findWorkExperiencesBulk / findManualAffiliationsBulk — exported separately for reuse
  • Conflict resolution mirrors prepareMemberOrganizationAffiliationTimeline but uses an interval-based approach (boundary dates) instead of day-by-day iteration, making it viable for bulk requests

Note

Medium Risk
Adds a new public endpoint plus new SQL-backed bulk affiliation resolution logic, and changes public API auth/routing (OAuth vs static API key), which could affect access control and response behavior.

Overview
Adds a new DevStats affiliations API that accepts a list of GitHub handles and returns contributor emails plus resolved, non-overlapping affiliation periods with paging.

To support this, introduces new data-access-layer modules: devStats queries for verified GitHub handles/emails and affiliations bulk-resolves affiliation timelines from work experiences + manual segment affiliations.

Public API routing/auth is reworked: OAuth2 is now applied per v1 route (/members, /organizations), while the new affiliations endpoint is mounted under /v1/member-organization-affiliations behind staticApiKeyMiddleware, and v1 now throws NotFoundError for unknown routes. Also adds a 400 response for invalid JSON bodies and reduces public API error logs to name/message/stack fields.

Written by Cursor Bugbot for commit 543c953. This will update automatically on new commits. Configure here.

@ulemons ulemons self-assigned this Mar 20, 2026
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conventional Commits FTW!

@ulemons ulemons changed the title Feat/add query layer feat: add query layer (CM-1059) Mar 20, 2026
@ulemons ulemons force-pushed the feat/add-query-layer branch 3 times, most recently from 9970c76 to e6f6aba Compare March 24, 2026 14:47
@ulemons ulemons marked this pull request as ready for review March 24, 2026 14:47
Copilot AI review requested due to automatic review settings March 24, 2026 14:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a DevStats-oriented query layer and exposes a new public API endpoint to bulk-resolve GitHub contributor affiliations (including timeline conflict resolution) from existing member work experience and manual affiliation data.

Changes:

  • Exports new DAL modules (affiliations, devStats) from the data-access-layer package.
  • Adds DAL query helpers for DevStats lookups (members by GitHub handle; verified emails by memberId).
  • Implements POST /v1/dev-stats/affiliations handler wired into the public router.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
services/libs/data-access-layer/src/index.ts Re-exports new DAL entrypoints so downstream services can consume them.
services/libs/data-access-layer/src/devStats/index.ts Adds DevStats-focused queries for bulk member lookup and verified emails.
services/libs/data-access-layer/src/affiliations/index.ts Introduces bulk affiliation resolution and timeline-building logic.
backend/src/api/public/v1/dev-stats/index.ts Wires the /affiliations route to the new handler with scope protection.
backend/src/api/public/v1/dev-stats/getAffiliations.ts Implements request validation, DAL lookups, and response shaping for the endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ulemons ulemons force-pushed the feat/add-query-layer branch from 7849e93 to da7a1a7 Compare March 25, 2026 09:42
@ulemons ulemons force-pushed the feat/add-query-layer branch from da7a1a7 to fe0c5a5 Compare March 25, 2026 09:53
@ulemons ulemons force-pushed the feat/add-query-layer branch from 6c63040 to 294f705 Compare March 25, 2026 11:19
@ulemons ulemons force-pushed the feat/add-query-layer branch from d713ebd to 080da1e Compare March 25, 2026 12:27
ulemons added 7 commits March 25, 2026 14:45
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
ulemons added 19 commits March 25, 2026 14:46
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons ulemons force-pushed the feat/add-query-layer branch from cdc78ea to 93824fe Compare March 25, 2026 13:46
ulemons added 4 commits March 25, 2026 15:17
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 4 total unresolved issues (including 3 from previous reviews).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

ulemons added 5 commits March 25, 2026 17:18
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants